package com.terrynoya.fight.stateMachine.controllers
{
	import com.terrynoya.fight.char.Character;
	import com.terrynoya.fight.char.Entity;
	import com.terrynoya.fight.evaluation.ExpressionRunner;
	import com.terrynoya.fight.stateMachine.StateController;
	import com.terrynoya.fight.stateMachine.controllers.attrParser.StateCtrlParserType;
	import com.terrynoya.geom.MVector2D;
	
	public class PosAdd extends StateController
	{
		public function PosAdd(name:String)
		{
			super(name);
		}
		
		override protected function initAttrConvertMap():void
		{
			this.attrConvertMap.put("x",StateCtrlParserType.Expression);
			this.attrConvertMap.put("y",StateCtrlParserType.Expression);
		}
		
		override public function run(character:Character):void
		{
			var x:Number = ExpressionRunner.excuteAsNumber(this.getExpression("x"),character);
			var y:Number = ExpressionRunner.excuteAsNumber(this.getExpression("y"),character);
			character.move(new MVector2D(x,y));
		}
	}
}